package com.leixin.demo.controller;

import com.leixin.demo.entity.RedisEntity;
import com.leixin.demo.entity.UserEntity;
import com.leixin.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping(value = "index")
public class UserController {
    @Autowired
    UserService userService;
    @PostMapping(value = "user")
    public void addUser(@RequestBody UserEntity userEntity){
        userEntity.setId(UUID.randomUUID().toString());
        userService.addUser(userEntity);
    }

    @GetMapping(value = "get")
    public List<String> get(){
        File file = new File("D:\\Pangu\\产品\\");
        List<String> list = new ArrayList<>();
        return userService.get(file,list);
    }

    @GetMapping(value = "getComment")
    public List getComment(){
        return userService.getComment();
    }

    @GetMapping(value = "saveComment")
    public String saveComment(String comment, HttpServletRequest request) throws IOException {
        return userService.saveComment(comment,request);
    }
}
